package com.gscitysfy.cus.drain.modules.warning.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.annotations.DictTranslation;
import com.gscitysfy.cus.drain.annotations.FieldParam;
import com.gscitysfy.cus.drain.constants.DicConstant;
import com.gscitysfy.cus.drain.modules.common.entity.DrainInspectionMnFile;
import com.gscitysfy.cus.drain.modules.common.service.IFileService;
import com.gscitysfy.cus.drain.modules.inspection.entity.DrainInspectionMnPlan;
import com.gscitysfy.cus.drain.modules.inspection.service.IDrainInspectionMnJobService;
import com.gscitysfy.cus.drain.modules.inspection.vo.PlanVo;
import com.gscitysfy.cus.drain.modules.warning.entity.DrainWaringSystem;
import com.gscitysfy.cus.drain.modules.warning.service.IDrainWaringSystemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  预警机制列表
 * </p>
 *
 * @author Administrator
 * @since 2022-10-20 19:15:57
 */
@RestController
@RequestMapping("/warning/drainWaringSystem")
public class DrainWaringSystemController {


    @Autowired
    IDrainWaringSystemService drainWaringSystemService;


    /**
     * 获取预警机制列表
     * @return
     */
    @Operation(summary = "获取预警机制列表")
    @GetMapping("/page")
    @Parameters({
            @Parameter(required = false, name = "warningSystemName", description = "预警机制名称"),
            @Parameter(required = false, name = "warningSystemType", description = "预警机制类型")
    })
    @DictTranslation({
            @FieldParam(dictType = DicConstant.WARNING_SYSTEM_TYPE, targetField = "warningSystemType"),
            @FieldParam(dictType = DicConstant.WARNING_SYSTEM_SOURCE, targetField = "warningSystemSource")
    })
    public Result<Object> page(@Parameter(hidden = true) Page<DrainWaringSystem> page, @Parameter(hidden = true) DrainWaringSystem drainWaringSystem){
        return drainWaringSystemService.getByPage(page, drainWaringSystem);
    }


    /**
     * 修改或者保存预警机制
     * @param drainWaringSystem
     * @return
     */
    @PostMapping("/save")
    @Operation(summary = "修改或者保存预警机制")
    @Parameters({
            @Parameter(required = false, name = "cmKid", description = "修改时必须，预警机制id"),
            @Parameter(required = false, name = "warningSystemName", description = "新增时必须，预警机制名称"),
            @Parameter(required = false, name = "warningSystemType", description = "新增时必须，预警机制类型"),
            @Parameter(required = false, name = "warningSystemSource", description = "新增时必须，预警机制来源"),
            @Parameter(required = false, name = "warningInfo", description = "预警描述"),
            @Parameter(required = false, name = "warningFileId", description = "文件id")
    })
    public Result<Boolean> addOrUpdate(@Parameter(hidden = true)@RequestBody DrainWaringSystem drainWaringSystem ){
      return  Result.content(drainWaringSystemService.saveOrUpdate(drainWaringSystem));
    }


    /**
     * 修改或者保存预警机制
     * @param drainWaringSystem
     * @return
     */
    @GetMapping("/del")
    @Operation(summary = "删除预警机制")
    @Parameters({
            @Parameter(required = false, name = "cmKid", description = "预警机制id")
    })
    public Result<Boolean> del(@Parameter(hidden = true) DrainWaringSystem drainWaringSystem ){

        return  drainWaringSystemService.del(drainWaringSystem);
    }


    /**
     * 获取预警机制详情
     * @return
     */
    @Operation(summary = "获取预警机制列表或者详情")
    @GetMapping("/listOrDetail")
    @Parameters({
            @Parameter(required = false, name = "warningSystemName", description = "预警机制名称"),
            @Parameter(required = false, name = "cmKid", description = "详情时必须，预警机制id"),
            @Parameter(required = false, name = "warningSystemType", description = "预警机制类型")
    })
    @DictTranslation({
            @FieldParam(dictType = DicConstant.WARNING_SYSTEM_TYPE, targetField = "warningSystemType"),
            @FieldParam(dictType = DicConstant.WARNING_SYSTEM_SOURCE, targetField = "warningSystemSource")
    })
    public Result<Object> listOrDetail(@Parameter(hidden = true) DrainWaringSystem drainWaringSystem){
        return drainWaringSystemService.getListByQuery( drainWaringSystem);
    }
}
